﻿
////////////////////////////////////////////////////////////////////////////////////////////
// 文件名: SysTBViewBLL.gen.cs
//
// 模块名称: SysTBView
//
// 作者: yqf
//
// 历史记录（记录修改记录，修改文件后请添加修改记录，注明修改时间、修改人，修改内容）:
// 2013-01-22    yqf    创建文件
////////////////////////////////////////////////////////////////////////////////////////////

using System;
using System.Data;
using System.Data.Common;
using System.Text;
using Model;
using DAL;
using Common;
using System.Collections.Generic;
using System.Data.SqlClient;

namespace BLL
{
    /// <summary>
    /// SysTBView表业务逻辑层
    /// </summary>
    public partial class SysTBViewBLL
    {

        public SysTBViewBLL(LoginInfo info)
        {
            loginInfo = info;
        }
        public LoginInfo loginInfo
        {
            get;
            set;
        }
        /// <summary>
        /// 更新SysTBView表记录
        /// </summary>
        /// <param name="SysTBView">SysTBView实体对象</param>
        public void Update(IDataParameter[] sqlparams, string proc)
        {
            try
            {
                SysTBViewDAL dal = new SysTBViewDAL(loginInfo);
                dal.Update(sqlparams, proc);
                new SysOperationLog(loginInfo).Log("视图管理", OperationAction.更新, OperationStatus.成功, "更新视图操作,操作成功", loginInfo.UserName);
            }
            catch (Exception ex)
            {
                new SysOperationLog(loginInfo).Log("视图管理", OperationAction.更新, OperationStatus.失败, "更新视图操作,操作失败：" + ex.Message, loginInfo.UserName);
            }
        }

        public bool CheckViewData(string sql)
        {
            try
            {
                SysTBViewDAL dal = new SysTBViewDAL(loginInfo);
                return dal.CheckViewData(sql);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysTBViewBLL", "CheckViewData", AppError.EROR, 0, ex, "CheckViewData信息出错。", "");
                return false;
            }
        }
        /// <summary>
        /// 根据ID字段获取SysTBView实体对象
        /// </summary>
        /// <param name="id">ID</param>
        public SysTBView GetItem(string id)
        {
            try
            {
                SysTBViewDAL dal = new SysTBViewDAL(loginInfo);
                return dal.GetItem(id);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysTBViewBLL", "GetItem", AppError.EROR, 0, ex, "取SysTBView信息出错。",
                                String.Format("id = {0}", id));
                return new SysTBView();
            }
        }
        public DataTable GetItem(string id, int type)
        {
            try
            {
                SysTBViewDAL dal = new SysTBViewDAL(loginInfo);
                return dal.GetItem(id, type);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysTBViewBLL", "GetItem", AppError.EROR, 0, ex, "取SysTBView信息出错。",
                                String.Format("id = {0}", id));
                return new DataTable();
            }
        }
        public string GetCreateTbScript(string viewID, string etlType)
        {
            try
            {
                SysTBViewDAL dal = new SysTBViewDAL(loginInfo);
                return dal.GetCreateTbScript(viewID, etlType);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysTBViewBLL", "GetCreateTbScript", AppError.EROR, 0, ex, "取GetCreateTbScript信息出错。", "");
                return "";
            }
        }
        public DataTable ExportData(string id)
        {
            try
            {
                SysTBViewDAL dal = new SysTBViewDAL(loginInfo);
                return dal.ExportData(id);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysTBViewBLL", "ExportData", AppError.EROR, 0, ex, "ExportData信息出错。",
                                String.Format("id = {0}", id));
                return new DataTable();
            }
        }
        public string GetAuditDetail(string id)
        {
            try
            {
                SysTBViewDAL dal = new SysTBViewDAL(loginInfo);
                return dal.GetAuditDetail(id);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysTBViewBLL", "GetItem", AppError.EROR, 0, ex, "取SysTBView信息出错。",
                                String.Format("id = {0}", id));
                return "";
            }
        }
        /// <summary>
        /// 根据ID字段删除SysTBView实体对象
        /// </summary>
        /// <param name="id">ID</param>
        public int Delete(string id)
        {
            try
            {
                SysTBViewDAL dal = new SysTBViewDAL(loginInfo);
                new SysOperationLog(loginInfo).Log("视图管理", loginInfo.UserIP, OperationAction.删除, OperationStatus.成功, "删除视图操作,操作成功", loginInfo.UserName);
                return dal.Delete(id);
            }
            catch (Exception ex)
            {
                new SysOperationLog(loginInfo).Log("视图管理", loginInfo.UserIP, OperationAction.删除, OperationStatus.失败, "删除视图操作,操作失败：" + ex.Message, loginInfo.UserName);
                return 0;
            }
        }
        public List<string> EditPushName(string id)
        {
            try
            {
                SysTBViewDAL dal = new SysTBViewDAL(loginInfo);
                return dal.EditPushName(id);
            }
            catch (Exception ex)
            {
                new SysOperationLog(loginInfo).Log("视图管理", loginInfo.UserIP, OperationAction.更新, OperationStatus.失败, "更新推送名称操作,操作失败：" + ex.Message, loginInfo.UserName);
                return new List<string>();
            }
        }
        public string SavePushName(string id, string pushName,string pushSchema)
        {
            try
            {
                SysTBViewDAL dal = new SysTBViewDAL(loginInfo);
                new SysOperationLog(loginInfo).Log("视图管理", loginInfo.UserIP, OperationAction.更新, OperationStatus.成功, "更新推送名称操作,操作成功", loginInfo.UserName);
                dal.SavePushName(id, pushName, pushSchema);
                return "操作成功！";
            }
            catch (Exception ex)
            {
                new SysOperationLog(loginInfo).Log("视图管理", loginInfo.UserIP, OperationAction.更新, OperationStatus.失败, "更新推送名称操作,操作失败：" + ex.Message, loginInfo.UserName);
                return ex.Message;
            }
        } 
        /// <summary>
        /// 根据ID字段删除Push实体对象
        /// </summary>
        /// <param name="id">ID</param>
        public string DeletePush(string id)
        {
            try
            {
                SysTBViewDAL dal = new SysTBViewDAL(loginInfo); 
                if (dal.DeletePush(id))
                {
                    new SysOperationLog(loginInfo).Log("视图推送管理", loginInfo.UserIP, OperationAction.删除, OperationStatus.成功, "删除视图推送信息操作,操作成功", loginInfo.UserName);
                    return "1";
                }
                else
                {
                    new SysOperationLog(loginInfo).Log("视图推送管理", loginInfo.UserIP, OperationAction.删除, OperationStatus.失败, "删除视图推送信息操作,操作失败.", loginInfo.UserName);
                    return "0";
                }
            }
            catch (Exception ex)
            {
                new SysOperationLog(loginInfo).Log("视图推送管理", loginInfo.UserIP, OperationAction.删除, OperationStatus.失败, "删除视图推送信息操作,操作失败：" + ex.Message, loginInfo.UserName);
                return ex.Message;
            }
        }
        /// <summary>
        /// 获取SysTBView实体数量
        /// </summary>
        /// <param name="id">ID</param>
        public int GetListCount(IDataParameter[] sqlparams)
        {
            try
            {
                SysTBViewDAL dal = new SysTBViewDAL(loginInfo);
                return dal.GetListCount(sqlparams);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysTBViewBLL", "GetListCount", AppError.EROR, 0, ex, "获取SysTBView实体数量出错。", "");
                return 0;
            }
        }
        /// <summary>
        /// 获取ApproveListCount实体数量
        /// </summary> 
        public int ApproveListCount(IDataParameter[] sqlparams)
        {
            try
            {
                SysTBViewDAL dal = new SysTBViewDAL(loginInfo);
                return dal.ApproveListCount(sqlparams);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysTBViewBLL", "ApproveListCount", AppError.EROR, 0, ex, "获取ApproveListCount实体数量出错。", "");
                return 0;
            }
        }
        /// <summary>
        /// 获取GetPushCount实体数量
        /// </summary> 
        public int GetPushCount(IDataParameter[] sqlparams)
        {
            try
            {
                SysTBViewDAL dal = new SysTBViewDAL(loginInfo);
                return dal.GetPushCount(sqlparams);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysTBViewBLL", "GetPushCount", AppError.EROR, 0, ex, "获取GetPushCount实体数量出错。", "");
                return 0;
            }
        }
        /// <summary>
        /// 根据ID字段获取SysTBView实体对象列表
        /// </summary>
        /// SqlParameter[] sqlparams</param>
        /// <returns>SysTBView实体对象列表</returns>
        public List<SysTBView> GetList(IDataParameter[] sqlparams)
        {
            try
            {
                SysTBViewDAL dal = new SysTBViewDAL(loginInfo);
                return dal.GetList(sqlparams);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysTBViewBLL", "GetInfoList", AppError.EROR, 0, ex, "获取SysTBView信息出错。", "");
                return new List<SysTBView>();
            }
        }
        public List<SysViewPush> GetPushList(IDataParameter[] sqlparams)
        {
            try
            {
                SysTBViewDAL dal = new SysTBViewDAL(loginInfo);
                return dal.GetPushList(sqlparams);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysTBViewBLL", "GetPushList", AppError.EROR, 0, ex, "获取GetPushList信息出错。", "");
                return new List<SysViewPush>();
            }
        }
        public DataTable PushConfig(IDataParameter[] sqlparams)
        {
            try
            {
                SysTBViewDAL dal = new SysTBViewDAL(loginInfo);
                return dal.PushConfig(sqlparams);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysTBViewBLL", "GetPushList", AppError.EROR, 0, ex, "获取GetPushList信息出错。", "");
                return new DataTable();
            }
        }
        /// <summary>
        /// 根据ID字段获取ApproveList实体对象列表
        /// </summary>
        /// SqlParameter[] sqlparams</param> 
        public List<SysViewApprove> ApproveList(IDataParameter[] sqlparams)
        {
            try
            {
                SysTBViewDAL dal = new SysTBViewDAL(loginInfo);
                return dal.ApproveList(sqlparams);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysTBViewBLL", "ApproveList", AppError.EROR, 0, ex, "获取ApproveList信息出错。", "");
                return new List<SysViewApprove>();
            }
        }
        public List<Test_BaseView> GetBaseViewList(string username)
        {
            try
            {
                SysTBViewDAL dal = new SysTBViewDAL(loginInfo);
                return dal.GetBaseViewList(username);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysTBViewBLL", "Test_BaseView", AppError.EROR, 0, ex, "获取BaseView信息出错。", "");
                return new List<Test_BaseView>();
            }
        }
        public DataSet SavedView(string id, string index)
        {
            try
            {
                SysTBViewDAL dal = new SysTBViewDAL(loginInfo);
                return dal.SavedView(id, index);
            }
            catch (Exception ex)
            {
                Logger.LogError("SysTBViewBLL", "SavedView", AppError.EROR, 0, ex, "获取View信息出错。", "");
                return new DataSet();
            }
        }

    }
}